class Modal{
  static loading = false;
  static load(title) {
    title = title || "等待中...";
    Modal.loading = true;
    wx.showLoading({
      title: title,
      mask: true
    })
  }
  static loadfinish() {
    Modal.loading = false;
    wx.hideLoading();
  }
  static showSuc(msg = '操作成功') {
    msg = msg || "操作成功";
    Modal.loading = false;
    wx.hideLoading();
    wx.showToast({
      title: msg,
      icon: 'success'
    });
  }
  static showErr(msg) {
    msg = msg ||"操作失败";
    Modal.loading = false;
    wx.hideLoading();
    wx.showToast({
      title: msg,
      icon: 'none'
    });
  }
  static showModal(msg,callback) {
    wx.showModal({
      title: '提示',
      content: msg,
      success(res) {
        if (res.confirm) {
          callback();
        } 
      }
    });
  }
  static hideLoading(){
    wx.hideLoading();
  }
}



module.exports = Modal